package com.zang.netty.nettyio.server;

import com.zang.netty.io.model.enums.SocketEnum;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * @author Zhang Qiang
 * @Date 2019/7/20 15:44
 */
public class ChildChannelHandler extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline().addLast(new TimeServerHandle());
    }

    public static void main(String[] args) throws InterruptedException {
        int port = SocketEnum.PORT.getNum();
        if (args != null && args.length > 0){
            try {
                port = Integer.valueOf(args[0]);
            }catch (NumberFormatException n){}
        }
        new TimeServerByNetty().bind(port);
    }

}
